package com.guagua.chat.base;

/**
 * 北京八度互联科技有限公司版权所有
 * Copyright (C) Badu Corporation. All Rights Reserved
 */
import java.io.Serializable;

public final class PaginationInfo
    implements Serializable {
  /*总记录数*/
  private int intRowCount = 0;
  /*总页数*/
  private int intPageCount = 0;
  /*每页的记录数*/
  private int intPageSize = 15;
  /*当前页码*/
  private int intPage = 1;
  /*是否后有下一页*/
  private boolean hasNext = false;
  /*是否有前一页*/
  private boolean hasPrevious = false;
  /*下一页页码*/
  private int nextPage;
  /*上一页页码*/
  private int prePage;

  public int getIntRowCount() {
    return intRowCount;
  }

  public int getIntPageCount() {
    return intPageCount;
  }

  public int getIntPageSize() {
    return intPageSize;
  }

  public int getIntPage() {
    return intPage;
  }

  public boolean isHasNext() {
    return hasNext;
  }

  public boolean isHasPrevious() {
    return hasPrevious;
  }

  public int getNextPage() {
    return nextPage;
  }

  public int getPrePage() {
    return prePage;
  }

  public void setIntRowCount(int intRowCount) {
    this.intRowCount = intRowCount;
  }

  public void setIntPageCount(int intPageCount) {
    this.intPageCount = intPageCount;
  }

  public void setIntPageSize(int intPageSize) {
    this.intPageSize = intPageSize;
  }

  public void setIntPage(int intPage) {
    this.intPage = intPage;
  }

  public void setHasNext(boolean hasNext) {
    this.hasNext = hasNext;
  }

  public void setHasPrevious(boolean hasPrevious) {
    this.hasPrevious = hasPrevious;
  }

  public void setNextPage(int nextPage) {
    this.nextPage = nextPage;
  }

  public void setPrePage(int prePage) {
    this.prePage = prePage;
  }

  /**
   * 设置分页的是否有上一页和下一页标志
   */
  public void setHasPrevious_Next() {

    if (this.getIntPage() < this.getIntPageCount() && this.getIntPage() > 1) {
      this.setHasNext(true);
      this.setHasPrevious(true);
    }
    else {
      if (this.getIntPageCount() != 1) {
        if (this.getIntPage() == 1) {
          this.setHasNext(true);
          this.setHasPrevious(false);
        }
        else {
          this.setHasNext(false);
          this.setHasPrevious(true);
        }
      }
    }

  }


  /**
   * 设置翻页信息
   * @param intpage int:显示第几页
   * @param pagesize int:每页显示条数
   * @param overallcount int:总页数
   */
  public PaginationInfo(int intpage, int pagesize,
                                 int overallcount) {
    /*设置当前页码*/
    this.setIntPage(intpage);
    /**设置每页的条数*/
    this.setIntPageSize(pagesize);
    /*设置上一页页码*/
    this.setPrePage(intpage - 1);
    /*设置下一页页码*/
    this.setNextPage(intpage + 1);
    /*设置总记录数*/
    this.setIntRowCount(overallcount);
    if (this.getIntRowCount() >= 1) {
      /*设置总页数*/
      this.setIntPageCount( (this.getIntRowCount() +
                                        this.getIntPageSize() - 1) /
                                      this.getIntPageSize());
      //设置是否有前页后一页标志
      this.setHasPrevious_Next();
      //设置了返回记录数
    }
  }

  /**
   * 默认构造函数
   */
  public PaginationInfo() {

  }



}
